var tplVS = 
	'<div>'+
		'<div class="item-img"><img src="resources/images/stock_icon.png" width="60" height="60"></div>'+
		'<div class="list-nroMaterial">{nroMaterial}</div>'+
		'<div class="list-descMaterial">{descMaterial}</div>'+
		'<div class="list-moneda">{precioMat} {moneda}</div>'+
		'<div class="list-cantMaterial">{cantMaterial}</div>'+
		'<div class="list-pesoMat">{pesoMat}</div>'+
	'</div>';

verStockView = Ext.extend(Ext.Panel, 
{
	fullscreen: true,
	layout: 'card',
		
	initComponent: function() 
	{
		this.listaVS = new Ext.List(
		{
			id: 'listaVS',
			grouped: false,
			itemTpl: tplVS,
			loadingText: false,
			store: verStockStore			
        });
        
		this.listaVS.on('selectionchange', this.onSelect, this);
		
		this.stockPanel = new Ext.Panel(
        {

            layout: 'fit',
            
            dockedItems: [
            {
                xtype: 'toolbar',
				dock: 'top',
                title: 'Lista de Materiales',
                layout: 
                {
                    pack: 'center'
                },
                items: [
                {
                	xtype: 'box'
                },
				{
					xtype: 'button',
					text: 'Volver',
					ui: 'confirm',
					handler: function()
					{
						window.open("listaPanel.html","_self");
					}
				},
				{
					xtype: 'spacer'
				}]
            }
            ],
            
            items: this.listaVS,
			
            listeners: 
            {
                activate: 
                { 
        			fn: function()
        			{
                    	this.listaVS.getSelectionModel().deselectAll();
                    	Ext.repaint();
        			}, 
        			scope: this 
        		}
            }
		
		});		
        
        this.items = this.stockPanel;
        
        verStockView.superclass.initComponent.call(this);
	},
        
    onSelect: function(selectionmodel, records)
    {
    	if (records[0] !== undefined) 
    	{
           var detalleVSCard = new detalleVerStock(
           {
        	   prevCard: this.stockPanel,
               record: records[0]
           });

           this.setActiveItem(detalleVSCard, 'slide');
        }
    }
});

Ext.reg('verStockView', verStockView);